const FileUploadMixin = {
    methods: {
        $_fileUpload: function (file, data = {},uploadUrl) {
            return new Promise((resolve, reject) => {
                let param = new FormData()
                // 通过append向form对象添加数据
                param.append('file', file, file.name)
                for (let key in data) {
                    param.append(key, data[key])
                }
                let headers = {
                    headers: {'Content-Type': 'multipart/form-data'},
                    baseURL: null,
                    dataType: 'json'
                }
                let url = uploadUrl
                if(!url){
                    url = this.$baseURL.file + '/file/cloudstorage/upload'
                }
                this.axios.post( url + '?t=' + (new Date().getTime() + Math.random()), param, headers)
                    .then(response => {
                        resolve(response)
                    }, err => {
                        reject(err)
                    })
            })
        }
    }
}
export default FileUploadMixin